package array.nowcoder.medium;

import java.util.Scanner;

/**
 * @author Stark
 * @description 不要2
 * @date 2022/4/23 16:03
 **/
public class DoNot2 {
    static int choice = 2;
    public static void main(String[] args) {
        //方法一
        //思路正确,可以只使用一个循环,把判断的条件反转一下
        //如方法二
        if(choice == 1) {
            Scanner in = new Scanner(System.in);
            while (in.hasNextInt()) {
                int col = in.nextInt();
                int row = in.nextInt();
                if (col <= 2 && row <= 2) {
                    System.out.println(col * row);
                } else {
                    int count = 4;
                    boolean[][] arr = new boolean[row][col];
                    for (int i = 0; i < row; i++) {
                        for (int j = 0; j < col; j++) {
                            if (i < 2 && j < 2) {
                                arr[i][j] = true;
                            } else {
                                if (i >= 2 && arr[i - 2][j]) {
                                    continue;
                                }
                                if (j >= 2 && arr[i][j - 2]) {
                                    continue;
                                }
                                arr[i][j] = true;
                                count++;
                            }
                        }
                    }
                    System.out.println(count);
                }
            }
        }
        
        //
        if(choice == 2){
            Scanner in = new Scanner(System.in);
            while (in.hasNextInt()) {
                int col = in.nextInt();
                int row = in.nextInt();
                boolean[][] arr = new boolean[row][col];
                int count = 0;
                for (int i = 0; i < row; i++) {
                    for (int j = 0; j < col; j++) {
                        if (arr[i][j] == false) {
                            count++;
                            if (i + 2 < row)
                                arr[i + 2][j] = true;
                            if (j + 2 < col)
                                arr[i][j + 2] = true;
                        }
                    }
                }
                System.out.println(count);
            }
        }
    }
}
